<!-- pass a variable to included page -->
<%@ page import="instructor.sample.*" %>
<%@ page import="java.text.*" %>
<%@ page import="java.util.*" %>
<%@ page import="java.sql.*" %>
<% 
   String today = null;
   Today t = new Today();
   today = t.getToday();
   request.setAttribute("picture","InstructorSamples");
   request.setAttribute("title", "User List (for internal use only)");  
   request.setAttribute("header", "Welcome : Today is " + today); 
 %>
 <%@ include file="header.jsp"%>
<TD width="850" vAlign="top"> 
<%	
OraDB myDB = new OraDB();
ResultSet rs = null;
myDB.createConnection();

%>
<br /><h2>User List</h2><br />
<table width=100% border=0>

<%
String myQuery = "Select u.userid, u.username, u.password, u.firstname, u.lastname, r.rolename, u.city, u.statecode " +
 "from users u, roles r where u.roleid = r.roleid order by 6 desc,5,4"; 

rs=myDB.Query(myQuery); 
String myrolename="";%>	 
				 
<%  while (rs.next()) {   
	if (myrolename.equals(rs.getString("rolename"))) {
	} else { 
		myrolename = rs.getString("rolename"); %>
		<tr>
		<th bgcolor="#3B73B9" style="color:white;">Role Name = <%=myrolename%></th>
		<th bgcolor="#3B73B9" style="color:white;">User ID</th>
		<th bgcolor="#3B73B9" style="color:white;">Name</th>
		<th bgcolor="#3B73B9" style="color:white;">User Name</th>
		<th bgcolor="#3B73B9" style="color:white;">Password</th>
		<th bgcolor="#3B73B9" style="color:white;">Location</th>
		</tr>
<%	} %>
        <tr>
        <td width="28%"><%=rs.getString("rolename")%></td>
		<td><%=rs.getString("userid")%></td>
		<td><%=rs.getString("lastname") + ", " + rs.getString("firstname")%></td>
		<td><%=rs.getString("username")%></td>
		<td><%=rs.getString("password")%></td>
		<td><%=rs.getString("city") + ", " + rs.getString("statecode")%></td>		
		</tr>
 <%  } %>
</table>
<%
rs.close();
myDB.closeConnection(); 
%>
</TD></TR></TABLE></body></html>